package com.gjintel.framework.paytype.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.gjintel.framework.paytype.dao.IPayTypeDao;
import com.gjintel.framework.paytype.model.PayType;
import com.gjintel.sdk.base.dao.HibernateGenericDAO;
import com.gjintel.sdk.base.dao.Page;
import com.gjintel.sdk.base.dao.Sort;
import com.gjintel.sdk.util.StringUtil;
/**
 * @description 商品类型数据处理实现
 * @author fengya
 * @date 2016-3-15 下午03:38:39
 */
@Repository("payTypeDao")
public class PayTypeDaoImpl extends HibernateGenericDAO implements IPayTypeDao{
	@SuppressWarnings("unchecked")
	public List<PayType> findAll() {
		String hql = "from PayType pa";
		return this.find(hql);
	}

	@SuppressWarnings("unchecked")
	public void findAll(Page page, PayType payType) {
		StringBuffer hql = new StringBuffer("from PayType pa ");
		List<Object> params = new ArrayList<Object>();
		if (payType != null) {
			if (!StringUtil.isEmpty(payType.getName())) {
				hql.append(" and pa.name like ? ");
				params.add("%" + payType.getName().trim() + "%");
			}
		}
		this.findAsPage(hql.toString(), page, null, "pa", true, params.toArray());
	}

	
}
